package com.fa4j.system.login.util;

import com.fa4j.common.base.exception.CommonRequestError;
import com.fa4j.common.web.util.ContextUtil;
import com.fa4j.system.login.dto.LoginSessionDTO;

public class LoginUtil {

    public static Long getAccountId() {
        return getSession().getAccountId();
    }

    public static LoginSessionDTO getSession() {
        LoginSessionDTO session = ContextUtil.get(LoginSessionDTO.class);
        if (session == null) {
            throw CommonRequestError.UNAUTHORIZED.build();
        }
        return session;
    }
}
